/*     */ package com.feeyin.radar.sys.service.impl;
/*     */ 
/*     */ import com.feeyin.radar.commons.StringUtils;
/*     */ import com.feeyin.radar.sys.dao.ManageSetDAO;
/*     */ import com.feeyin.radar.sys.dao.RoleDAO;
/*     */ import com.feeyin.radar.sys.dao.UserDAO;
/*     */ import com.feeyin.radar.sys.model.ManageSet;
/*     */ import com.feeyin.radar.sys.model.ManageSetObject;
/*     */ import com.feeyin.radar.sys.model.Role;
/*     */ import com.feeyin.radar.sys.model.Users;
/*     */ import com.feeyin.radar.sys.service.WarningService;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ public class WarningServiceImpl
/*     */   implements WarningService
/*     */ {
/*     */   private RoleDAO roleDAO;
/*     */   private UserDAO userDAO;
/*     */   private ManageSetDAO manageSetDAO;
/*     */ 
/*     */   public RoleDAO getRoleDAO()
/*     */   {
/*  31 */     return this.roleDAO;
/*     */   }
/*     */ 
/*     */   public void setRoleDAO(RoleDAO roleDAO) {
/*  35 */     this.roleDAO = roleDAO;
/*     */   }
/*     */ 
/*     */   public UserDAO getUserDAO() {
/*  39 */     return this.userDAO;
/*     */   }
/*     */ 
/*     */   public void setUserDAO(UserDAO userDAO) {
/*  43 */     this.userDAO = userDAO;
/*     */   }
/*     */ 
/*     */   public ManageSetDAO getManageSetDAO() {
/*  47 */     return this.manageSetDAO;
/*     */   }
/*     */ 
/*     */   public void setManageSetDAO(ManageSetDAO manageSetDAO) {
/*  51 */     this.manageSetDAO = manageSetDAO;
/*     */   }
/*     */ 
/*     */   public List getRoleUsers() {
/*  55 */     List roles = new ArrayList();
/*  56 */     roles = this.roleDAO.getRoles();
/*  57 */     if (roles == null) return null;
/*     */ 
/*  59 */     List users = new ArrayList();
/*  60 */     users = this.userDAO.getActivityUsers();
/*     */ 
/*  62 */     for (int i = 0; i < roles.size(); i++) {
/*  63 */       Role role = new Role();
/*  64 */       role = (Role)roles.get(i);
/*  65 */       if (users != null) {
/*  66 */         for (int j = 0; j < users.size(); j++) {
/*  67 */           Users user = new Users();
/*  68 */           user = (Users)users.get(j);
/*  69 */           if (role.getId().compareTo(user.getRoleId()) == 0) {
/*  70 */             role.getUsers().add(user);
/*     */           }
/*     */         }
/*     */       }
/*     */     }
/*  75 */     return roles;
/*     */   }
/*     */ 
/*     */   public Map getWarningPlan() {
/*  79 */     Map map = new HashMap();
/*  80 */     List warningPlans = new ArrayList();
/*  81 */     warningPlans = this.manageSetDAO.getManageSetByType("7");
/*  82 */     if (warningPlans == null) return null;
/*  83 */     for (int i = 0; i < warningPlans.size(); i++) {
/*  84 */       ManageSet manageSet = new ManageSet();
/*  85 */       manageSet = (ManageSet)warningPlans.get(i);
/*  86 */       if ("employeeBirthday".equals(manageSet.getCode()))
/*  87 */         map.put("w1", manageSet);
/*  88 */       else if ("auditRemind".equals(manageSet.getCode()))
/*  89 */         map.put("w2", manageSet);
/*  90 */       else if ("customerBirthday".equals(manageSet.getCode()))
/*  91 */         map.put("w3", manageSet);
/*  92 */       else if ("scheduleRemind".equals(manageSet.getCode()))
/*  93 */         map.put("w4", manageSet);
/*  94 */       else if ("visitRemind".equals(manageSet.getCode()))
/*  95 */         map.put("w5", manageSet);
/*  96 */       else if ("openSeaRemind".equals(manageSet.getCode()))
/*  97 */         map.put("w6", manageSet);
/*  98 */       else if ("contractRemind".equals(manageSet.getCode())) {
/*  99 */         map.put("w7", manageSet);
/*     */       }
/*     */     }
/* 102 */     return map;
/*     */   }
/*     */ 
/*     */   public Map getWarningWay() {
/* 106 */     Map map = new HashMap();
/* 107 */     List warningWays = new ArrayList();
/* 108 */     warningWays = this.manageSetDAO.getManageSetByType("8");
/* 109 */     if (warningWays == null) return null;
/* 110 */     for (int i = 0; i < warningWays.size(); i++) {
/* 111 */       ManageSet manageSet = new ManageSet();
/* 112 */       manageSet = (ManageSet)warningWays.get(i);
/* 113 */       if ("jobPortal".equals(manageSet.getCode()))
/* 114 */         map.put("way1", manageSet);
/* 115 */       else if ("internal".equals(manageSet.getCode()))
/* 116 */         map.put("way2", manageSet);
/* 117 */       else if ("email".equals(manageSet.getCode())) {
/* 118 */         map.put("way3", manageSet);
/*     */       }
/*     */     }
/* 121 */     map.put("isWay", Boolean.valueOf(this.manageSetDAO.isStartWarning()));
/* 122 */     return map;
/*     */   }
/*     */ 
/*     */   public boolean insertWarningWay(String[] ways) {
/* 126 */     if (ways == null) return false;
/* 127 */     if (ways.length <= 0) return false;
/*     */ 
/* 129 */     ManageSet manageSet = new ManageSet();
/* 130 */     manageSet.setMType("8");
/* 131 */     manageSet.setStatus("0");
/* 132 */     manageSet.setMValue("0");
/* 133 */     this.manageSetDAO.updateManageSetByType(manageSet);
/*     */ 
/* 135 */     manageSet = new ManageSet();
/* 136 */     manageSet.setMType("7");
/* 137 */     manageSet.setStatus("0");
/* 138 */     manageSet.setMValue("0");
/* 139 */     this.manageSetDAO.updateManageSetByType(manageSet);
/*     */ 
/* 141 */     this.manageSetDAO.deleteManageSetObjectByType("7");
/*     */ 
/* 143 */     for (int i = 0; i < ways.length; i++) {
/* 144 */       manageSet = new ManageSet();
/* 145 */       String code = "";
/* 146 */       if ("1".equals(ways[i]))
/* 147 */         code = "jobPortal";
/* 148 */       else if ("2".equals(ways[i]))
/* 149 */         code = "internal";
/* 150 */       else if ("3".equals(ways[i])) {
/* 151 */         code = "email";
/*     */       }
/* 153 */       if (!StringUtils.isEmpty(code)) {
/* 154 */         manageSet.setCode(code);
/* 155 */         manageSet.setStatus("1");
/* 156 */         manageSet.setMValue("0");
/* 157 */         this.manageSetDAO.updateManageSetByCode(manageSet);
/*     */       }
/*     */     }
/*     */ 
/* 161 */     manageSet = new ManageSet();
/* 162 */     manageSet.setMType("9");
/* 163 */     manageSet.setStatus("1");
/* 164 */     manageSet.setMValue("0");
/* 165 */     this.manageSetDAO.updateManageSetByType(manageSet);
/*     */ 
/* 167 */     return true;
/*     */   }
/*     */ 
/*     */   public boolean insertWarningItem(String warningItem, String userIds) {
/* 171 */     if (StringUtils.isEmpty(warningItem)) return false;
/* 172 */     if (StringUtils.isEmpty(userIds)) return false;
/* 173 */     ManageSet manageSet = new ManageSet();
/* 174 */     String code = "";
/* 175 */     if ("1".equals(warningItem))
/* 176 */       code = "employeeBirthday";
/* 177 */     else if ("2".equals(warningItem))
/* 178 */       code = "auditRemind";
/* 179 */     else if ("3".equals(warningItem))
/* 180 */       code = "customerBirthday";
/* 181 */     else if ("4".equals(warningItem))
/* 182 */       code = "scheduleRemind";
/* 183 */     else if ("5".equals(warningItem))
/* 184 */       code = "visitRemind";
/* 185 */     else if ("6".equals(warningItem))
/* 186 */       code = "openSeaRemind";
/* 187 */     else if ("7".equals(warningItem)) {
/* 188 */       code = "contractRemind";
/*     */     }
/*     */ 
/* 191 */     if (!StringUtils.isEmpty(code)) {
/* 192 */       manageSet.setCode(code);
/* 193 */       manageSet.setStatus("1");
/* 194 */       manageSet.setMValue(userIds);
/* 195 */       boolean result = this.manageSetDAO.updateManageSetByCode(manageSet);
/* 196 */       if (result) {
/* 197 */         insertWarningObject(code, userIds);
/*     */       }
/*     */     }
/* 200 */     return true;
/*     */   }
/*     */ 
/*     */   public boolean stopWarningPlan() {
/* 204 */     ManageSet manageSet = new ManageSet();
/* 205 */     manageSet.setMType("9");
/* 206 */     manageSet.setStatus("0");
/* 207 */     manageSet.setMValue("0");
/* 208 */     return this.manageSetDAO.updateManageSetByType(manageSet);
/*     */   }
/*     */ 
/*     */   private void insertWarningObject(String code, String userIds)
/*     */   {
/* 217 */     ManageSet manageSet = new ManageSet();
/* 218 */     manageSet = this.manageSetDAO.getManageSetByCode(code);
/* 219 */     if (manageSet != null)
/*     */     {
/* 222 */       String[] strUserIds = userIds.split(",");
/* 223 */       for (int i = 0; i < strUserIds.length; i++)
/* 224 */         if (!StringUtils.isEmpty(strUserIds[i])) {
/* 225 */           ManageSetObject mObject = new ManageSetObject();
/* 226 */           mObject.setManageSetId(manageSet.getId());
/* 227 */           mObject.setOtherId(Integer.valueOf(Integer.parseInt(strUserIds[i])));
/* 228 */           mObject.setManageSetCode(code);
/* 229 */           mObject.setManageSetType("7");
/* 230 */           this.manageSetDAO.insertManageSetObject(mObject);
/*     */         }
/*     */     }
/*     */   }
/*     */ 
/*     */   public boolean isUseAuditWarningByUserId(Integer userId)
/*     */   {
/* 238 */     if (!this.manageSetDAO.isStartWarning()) return false;
/*     */ 
/* 240 */     ManageSet manageSet = new ManageSet();
/* 241 */     manageSet = this.manageSetDAO.getManageSetByCode("auditRemind");
/* 242 */     if (manageSet == null) return false;
/* 243 */     if ((StringUtils.isEmpty(manageSet.getStatus())) || (!"1".equals(manageSet.getStatus()))) return false;
/* 244 */     String userIds = StringUtils.getSubLastComma(manageSet.getMValue());
/* 245 */     if (StringUtils.isEmpty(userIds)) return false;
/* 246 */     return userIds.indexOf(userId.toString()) > -1;
/*     */   }
/*     */ }

/* Location:           C:\Users\e547415\MyProject\rone\WEB-INF\classes\
 * Qualified Name:     com.feeyin.radar.sys.service.impl.WarningServiceImpl
 * JD-Core Version:    0.6.0
 */